﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfUserLogin.aspx.cs" Inherits="msBsc.WebUi.wMall.Public.wfUserLogin" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="地接客旅游，包车，租车，旅游包车专家，旅游因您而定" />
    <title>用户登陆</title>
    <link href="/themes/wStyle1/css/sLayout.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sHead.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sFoot.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/Public/sLogin.css" rel="stylesheet" />
</head>
<body>
    <%=msBsc.WebUi.Code.QtHtmlGet.GetHeaderLoginInfo() %>
    <div class="wf_all">
        <div id="divLoginInfo">
         <%--   <%=msBsc.WebUi.Code.QtHtmlGet.GetHeader("欢迎登录") %>--%>
        </div>
        <div class="wrap">
            <div class="Login_content">
                <div class="login_register_items">
                    <span id="loginItem" onclick="javascript:{0}">登录<span class="EnTitle">Login</span></span>
                </div>
                <div id="login_notice"></div>
                <div class="user_input login_username">
                    <input type="text" id="txtUserName" value="请输入账号" />
                </div>
                <div class="user_input login_password">
                    <input type="text" id="txtPromtPassword" value="请输入密码" />
                    <input type="password" id="pwdPassword" style="display: none" value="" />
                </div>
                <div class="user_input login_viladatacode">
                    <input type="text" id="txtValidata" value="请输入验证码" />
                    <div id="imgValidata" class="img_validata" ></div> 
                </div>
                <div class="login_forgetpassword">
                    <input type="checkbox" id="isCheck" checked="checked" /><label for="isCheck">记住密码</label><span><a href="/wp_ForgotPassword.htm">忘记密码</a></span>
                </div>
                <div class="login_submit">
                    <input type="button" class="button_submit" id="button_submit" onclick="Login('login')" value="登 录" />
                    <input type="button" class="button_submit register" onclick="window.location.href = 'wp_UserRegister.htm'" value="注 册" />
                </div>
            </div>
        </div>
        <input type="hidden" id="txtReturnUrl" value="" />
        <%=msBsc.WebUi.Code.QtHtmlGet.GetFloorHtml() %>
    </div>
    <!--start JS引用-->
    <script src="/jqPlugin/js/jquery-1.8.3.min.js"></script>
    <script src="/jqPlugin/js/jBase.js"></script>
    <script src="/jqPlugin/js/jBPage.js"></script>
    <script src="/jqPlugin/js/laytpl.js"></script>
    <script src="/jqPlugin/js/jquery.cookie.js"></script>
    <script src="/themes/wStyle1/js/comm/VerifyJs.js"></script>
    <!--end JS引用-->
    <script type="text/ecmascript">
        (function () {
            $("#txtReturnUrl").val(GetQueryStr("ReturnUrl"));

            jQuery.getValidateImg('imgValidata');
            //回车登录
            document.onkeydown = function (e) {
                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    Login("login");
                }
            }

            CheckInput();
            //初始化用户信息

            $("#txtUserName").val("请输入账号");
            $("#txtValidata").val("请输入验证码");
            var opart = new jsonRow();
            opart = addNoAreStatistics(opart, "", "w0001");

            opart.AddCell("ACTION", "init");
            if ($.cookie("rmbUser") == "true") {
                $("#txtUserName").val($.cookie("account")).css("color", "#000");
                $("#txtPromtPassword").hide();
                $("#pwdPassword").show().css("color", "#000");
                $("#txtValidata").val("").css("color", "#000").focus();

                opart.AddCell("password", $.cookie("password"));
                ajaxComm(opart);
            } else {
                opart.AddCell("password", "");
                ajaxComm(opart);
            }

            ChangeOnTime();
        })();

        //登录成功，页面跳转
        function susccLogin() {
            if ($("#txtReturnUrl").val() != '') {
                window.location.href = $("#txtReturnUrl").val();
            } else {
                window.location.href = "/";
            }
        }

        //及时响应操作
        function ChangeOnTime() {
            $("#txtValidata").keypress(function () {
                var ErrorMessage = $("#login_notice").text();
                var ValiStr = $(this).val();
                if (ErrorMessage.indexOf("验证码") >= 0 && ValiStr != "请输入验证码") {
                    $("#login_notice").text("");
                }
            })

            $("#txtUserName").keypress(function () {
                var ErrorMessage = $("#login_notice").text();
                var ValiStr = $(this).val();
                if (ErrorMessage.indexOf("用户名") >= 0 && ValiStr != "请输入账号") {
                    $("#login_notice").text("");
                }
            })

            $("#pwdPassword").keypress(function () {
                var ErrorMessage = $("#login_notice").text();
                var ValiStr = $(this).val();
                if (ErrorMessage.indexOf("密码") >= 0 && ValiStr != "请输入密码") {
                    $("#login_notice").text("");
                }
            })
        }


        //判断输入框应显示的内容
        function CheckInput() {
            var InputUserName = "请输入账号";
            var InputPassword = "请输入密码";
            var InputValidata = "请输入验证码";

            $("#txtUserName").focus(function () {
                if ($(this).val() == InputUserName) {
                    $(this).val("").css("color", "#000");
                }
            }).blur(function () {
                var UserName = $(this).val();
                if (IsNull(UserName)) {
                    $(this).val(InputUserName).css("color", "#9d9d9d");
                }
            });

            $("#txtPromtPassword").focus(function () {
                $(this).hide();
                $("#pwdPassword").show().css("color", "#000").focus().blur(function () {
                    var Password = $(this).val();
                    if (IsNull(Password)) {
                        $(this).hide();
                        $("#txtPromtPassword").show();
                    }
                });
            })

            $("#txtValidata").focus(function () {
                var Validata = $(this).val();
                if ($(this).val() == InputValidata) {
                    $(this).val("").css("color", "#000");
                }
            }).blur(function () {
                var Validata = $(this).val();
                if (IsNull(Validata)) {
                    $(this).css("color", "#9d9d9d").val(InputValidata);
                }
            })
        }

        var GtGrid1Action;
        //登录功能
        function Login(sEbtn) {

            var UserName = $.trim($("#txtUserName").val());
            if (!vfcUser(UserName)) {//验证用户名
                return;
            }

            var Password = $.trim($("#pwdPassword").val());
            if (!vfcPassword(Password)) {//验证密码
                return;
            }

            var ValidataCode = $.trim($("#txtValidata").val());
            //验证验证码是否为空
            if (IsNull(ValidataCode) || ValidataCode == "请输入验证码") {
                $("#login_notice").text("*验证码不能为空");
                return false;
            }
            if (!vfcCode(ValidataCode)) {//验证验证码
                ChangeValidata();
                return;
            }
            btnDo(sEbtn, UserName, Password, ValidataCode)
        }

        function btnDo(sEbtn, UserName, Password, ValidataCode) {
            GtGrid1Action = sEbtn;
            var opart = GetGtParam(UserName, Password, ValidataCode);
            ajaxComm(opart);
        };

        //执行AJAX调用时获取参数
        function GetGtParam(account, password, code) {
            var _jsParam = new jsonRow();
            _jsParam.AddCell("account", account);
            _jsParam.AddCell("password", password);
            _jsParam.AddCell("code", code);
            _jsParam.AddCell("ACTION", GtGrid1Action);
            return _jsParam;
        };

        //验证用户名
        function vfcUser(UserNameStr) {
            if (IsNull(UserNameStr)) {
                $("#login_notice").text("*用户名不能为空");
                return false;
            }
            //if (!IsEmail(UserNameStr)) {
            //    $("#login_notice").text("*用户名只能是邮箱");
            //    return false;
            //}
            return true;
        }

        //验证密码
        function vfcPassword(PasswordStr) {
            if (IsNull(PasswordStr)) {
                $("#login_notice").text("*密码不能为空");
                return false;
            }
            if (!islength(PasswordStr, 6, 16)) {
                $("#login_notice").text("*密码长度只能在6~16为之间");
                return false;
            }
            return true;
        }

        //验证验证码
        function vfcCode(ValidataCode) {
            if (ValidataCode.length != 4) {
                $("#login_notice").text("*验证码长度只能是四位");
                return false;
            }
            if (!isStr(ValidataCode)) {
                $("#login_notice").text("*验证码只能是数字和字母组合");
                return false;
            }
            return true;
        }

        //保存cookie
        function setCookie(account, pwd) {
            if ($("#isCheck").prop("checked")) {//判断是否要记住密码
                $.cookie("rmbUser", "true", { expires: 10 });
                $.cookie("account", account, { expires: 10 });
                $.cookie("password", pwd, { expires: 10 });
            } else {
                $.cookie("rmbUser", "false", { expires: -1 });
                $.cookie("account", "", { expires: -1 });
                $.cookie("password", "", { expires: -1 });
            }
        }
    </script>
</body>
</html>
